/*
========================================================================
 Name        : ExportContactsStartContainerView.cpp
 Author      : autonavi.com
 Copyright   : autonavi.com,All Right Reserved!
 Description : 
========================================================================
*/
 
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <akncontext.h>
#include <akntitle.h>
#include <stringloader.h>
#include <barsread.h>
#include <eikbtgpc.h>
#include <ExportContacts.rsg>
 

#include "ExportContacts.hrh"
#include "ExportContactsStartContainerView.h"
#include "ExportContactsListBox.hrh"
#include "ExportContactsSelectDirContainer.hrh"
#include "ExportContactsExportingContainer.hrh"
#include "ExportContactsStartContainer.h"
 
CExportContactsStartContainerView::CExportContactsStartContainerView()
{	 
	iExportContactsStartContainer = NULL;
}

 
CExportContactsStartContainerView::~CExportContactsStartContainerView()
{	 
	delete iExportContactsStartContainer;
	iExportContactsStartContainer = NULL;	
}

 
CExportContactsStartContainerView* CExportContactsStartContainerView::NewL()
{
	CExportContactsStartContainerView* self = CExportContactsStartContainerView::NewLC();
	CleanupStack::Pop( self );
	return self;
}

 
CExportContactsStartContainerView* CExportContactsStartContainerView::NewLC()
{
	CExportContactsStartContainerView* self = new ( ELeave ) CExportContactsStartContainerView();
	CleanupStack::PushL( self );
	self->ConstructL();
	return self;
}

 
void CExportContactsStartContainerView::ConstructL()
{	 
	BaseConstructL( R_EXPORT_CONTACTS_START_CONTAINER_EXPORT_CONTACTS_START_CONTAINER_VIEW );
}

 
TUid CExportContactsStartContainerView::Id() const
{
	return TUid::Uid( EExportContactsStartContainerViewId );
}

 
void CExportContactsStartContainerView::HandleCommandL( TInt aCommand )
{	 
	TBool commandHandled = EFalse;
	switch ( aCommand )
	{	 
		default:
			break;
	}	
	if ( !commandHandled ) 
	{
	
		if ( aCommand == EAknSoftkeyExit )
		{
			AppUi()->HandleCommandL( EEikCmdExit );
		}
	
	}
}
 
void CExportContactsStartContainerView::DoActivateL( const TVwsViewId& aPrevViewId,
													 TUid aCustomMessageId,
													 const TDesC8& aCustomMessage )

{
 
	SetupStatusPaneL();				
	if ( iExportContactsStartContainer == NULL )
	{
		iExportContactsStartContainer = CreateContainerL();
		iExportContactsStartContainer->SetMopParent( this );
		AppUi()->AddToStackL( *this, iExportContactsStartContainer );
	} 	
}

 
void CExportContactsStartContainerView::DoDeactivate()
{	 
	CleanupStatusPane();
	
	if ( iExportContactsStartContainer != NULL )
	{
		AppUi()->RemoveFromViewStack( *this, iExportContactsStartContainer );
		delete iExportContactsStartContainer;
		iExportContactsStartContainer = NULL;
	}
}
 
void CExportContactsStartContainerView::HandleStatusPaneSizeChange()
{
	CAknView::HandleStatusPaneSizeChange();	 
	TVwsViewId view;
	AppUi()->GetActiveViewId( view );
	if ( view.iViewUid == Id() )
	{
		TInt result;
		TRAP( result, SetupStatusPaneL() );
	}
}

 
void CExportContactsStartContainerView::SetupStatusPaneL()
{
	// reset the context pane
	TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
	CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
		StatusPane()->PaneCapabilities( contextPaneUid );
	if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
	{
		CAknContextPane* context = static_cast< CAknContextPane* > ( 
			StatusPane()->ControlL( contextPaneUid ) );
		context->SetPictureToDefaultL();
	}
	
	// setup the title pane
	TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
	CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
		StatusPane()->PaneCapabilities( titlePaneUid );
	if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
	{
		CAknTitlePane* title = static_cast< CAknTitlePane* >( 
			StatusPane()->ControlL( titlePaneUid ) );
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_EXPORT_CONTACTS_START_CONTAINER_TITLE_RESOURCE );
		title->SetFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
	}
				
}
 
void CExportContactsStartContainerView::CleanupStatusPane()
{
}

CExportContactsStartContainer* CExportContactsStartContainerView::CreateContainerL()
{
	return CExportContactsStartContainer::NewL(AppUi()->ApplicationRect(), NULL, this );
}

